package client.interactor;

import javax.media.j3d.Transform3D;
import javax.vecmath.Quat4d;
import javax.vecmath.Vector3d;

import client.controller.Universe3DController;
import client.controller.Virtual3DController;

//Classe permettant l'interaction avec l'objet selectionne ou le viewpoint selectionne
public class Interactor {
	
	private Virtual3DController interactiveObject;
	private Universe3DController universe;
	
	public Interactor(Universe3DController u) {
		universe = u;
	}
	
	public void setInteractiveObject(Virtual3DController o) {
		this.interactiveObject = o;
	}
	
	public void translateInGlobal(double x, double y, double z) {
		
	}
	
	public void rotateInGlobal(double x, double y, double z) {
		
	}
	
	public void translateInLocal(double x, double y, double z) {
		Vector3d translate = new Vector3d();
		translate.set(x, y, z);
		Transform3D transT = new Transform3D();
		transT.set(translate);
		
		Transform3D oldT = interactiveObject.getTransform();
		
		Vector3d newPosition = new Vector3d();
		Transform3D newT = new Transform3D();
		
		newT.mul(oldT, transT);
		newT.get(newPosition);
		interactiveObject.setTransform(newT);
	}
	
	public void rotateInLocal(double x, double y, double z) {
		Vector3d rotate = new Vector3d();
		rotate.set(x, y, z);
		Transform3D rotaT = new Transform3D();
		rotaT.setEuler(rotate);
		
		Transform3D oldT = interactiveObject.getTransform();
		
		Quat4d newOrientation = new Quat4d();
		Transform3D newT = new Transform3D();
		
		newT.mul(oldT, rotaT);
		newT.get(newOrientation);
		
		interactiveObject.setTransform(newT);
	}

	public void translateInViewpoint(double x, double y, double z) {
		
	}
	
	public void rotateInViewpoint(double x, double y, double z) {
		
	}
}
